﻿// Ion.Sound
// version 1.3.0 Build: 20
// https://github.com/IonDen/ion.sound
(function(c){if(!c.ionSound){var e={},f,g,k,b,d={},l=!1,m=function(h){var a,b;-1!==h.indexOf(":")?(a=h.split(":")[0],b=h.split(":")[1]):a=h;d[a]=new Audio;g=d[a].canPlayType("audio/mp3");k="probably"===g||"maybe"===g?e.path+a+".mp3":e.path+a+".ogg";c(d[a]).prop("src",k);d[a].load();d[a].preload="auto";d[a].volume=b||e.volume},n=function(b){var a,c,f,g;-1!==b.indexOf(":")?(c=b.split(":")[0],f=b.split(":")[1]):c=b;a=d[c];if("object"===typeof a&&null!==a)if(f&&(a.volume=f),!e.multiPlay&&!l)a.play(),l=!0,g=setInterval(function(){a.ended&&(clearInterval(g),l=!1)},250);else if(e.multiPlay){if(!a.ended)try{a.currentTime=0}catch(k){}a.play()}};c.ionSound=function(g){e=c.extend({sounds:["water_droplet"],path:MyHOSTNAME+"/static/sounds/",multiPlay:!0,volume:"0.5"},g);f=e.sounds.length;if("function"===typeof Audio||"object"===typeof Audio)for(b=0;b<f;b+=1)m(e.sounds[b]);c.ionSound.play=function(a){n(a)};c.ionSound.stop=function(a){a=d[a];if("object"===typeof a&&null!==a){a.pause();try{a.currentTime=0}catch(b){}}};c.ionSound.kill=function(a){var b=d[a];if("object"===typeof b&&null!==b){try{d[a].src=""}catch(c){}d[a]=null}}};c.ionSound.destroy=function(){for(b=0;b<f;b+=1)d[e.sounds[b]]=null;f=0;c.ionSound.play=function(){};c.ionSound.stop=function(){};c.ionSound.kill=function(){}}}})(jQuery);